package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.EmrInfoOdsCopyMapper;
import com.ruoyi.system.domain.EmrInfoOdsCopy;
import com.ruoyi.system.service.IEmrInfoOdsCopyService;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * emr原始数据Service业务层处理
 *
 * @author XZB
 * @date 2021-11-17
 */
@Service
public class EmrInfoOdsCopyServiceImpl extends ServiceImpl<EmrInfoOdsCopyMapper, EmrInfoOdsCopy> implements IEmrInfoOdsCopyService {

    @Override
    public EmrInfoOdsCopy selectById(Long id) {
        return this.baseMapper.selectById(id);
    }

    @Override
    public List<EmrInfoOdsCopy> selectList(EmrInfoOdsCopy emrInfoOdsCopy) {
        QueryWrapper<EmrInfoOdsCopy> qw = new QueryWrapper<>();
        Map<String, Object> map = new HashMap<>();
        qw.select("*")
          // .like(StringUtils.isNotBlank(emrInfoOdsCopy.getId().toString()), "", emrInfoOdsCopy.getId())
           .allEq(map, false);
        return this.baseMapper.selectList(qw);
    }

    @Override
    public int insert(EmrInfoOdsCopy emrInfoOdsCopy) {
        return this.baseMapper.insert(emrInfoOdsCopy);
    }

    @Override
    public int update(EmrInfoOdsCopy emrInfoOdsCopy) {
        UpdateWrapper<EmrInfoOdsCopy> uw = new UpdateWrapper<>();
        uw.set("",emrInfoOdsCopy.getId())
            .eq("",emrInfoOdsCopy.getId());
        return this.baseMapper.update( null, uw);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public int deleteByIds(Long[] ids) {
        return this.baseMapper.deleteBatchIds(Arrays.asList(ids));
    }

    @Override
    public int deleteById(Long id) {
        return this.baseMapper.deleteById(id);
    }
}
